#{extends 'backend_main.html' /}
<div class="x-nav">
    <span class="layui-breadcrumb"><a>首页</a><a>管理员管理</a><a><cite>角色管理</cite></a></span>
    <a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
  <div class="x-body">
    <xblock>
      <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
      <button class="layui-btn" onclick="x_admin_show('添加角色','/SystemCenter/roleEdit?v=view&id=0')"><i class="layui-icon"></i>添加</button>
      <span class="x-right" style="line-height:40px">共有数据：${pageBean?.totalCount} 条</span>
    </xblock>
    <table class="layui-table" lay-size="sm">
      <thead>
        <tr>
          <th>
            <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
          </th>
          <th>ID</th>
          <th>角色名</th>
          <th>操作</th>
      </thead>
      <tbody>
      #{list pageBean?.page}
        <tr>
          <td>
            <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='${_?.id}'><i class="layui-icon">&#xe605;</i></div>
          </td>
          <td>${_?.id}</td>
          <td>${_?.role_name}</td>
          <td class="td-manage">
            <a title="编辑"  onclick="x_admin_show('编辑','/SystemCenter/roleEdit?id=${_?.id}&v=view')" href="javascript:;" class="layui-btn layui-btn-xs">
                编辑
            </a>
            <a title="权限"  onclick="x_admin_show('权限','/SystemCenter/addPermission?id=${_?.id}&v=view')" href="javascript:;" class="layui-btn layui-btn-xs layui-btn-danger">
                权限设置
            </a>
          </td>
        </tr>
      #{/list}
      </tbody>
    </table>
  #{page currPage:pageBean?.currPage,totalCount:pageBean?.totalCount,pageSize:pageBean?.pageSize,theme:2,style:1 /}
  </div>
  <script>
    layui.use('laydate', function(){
      var laydate = layui.laydate;
      //执行一个laydate实例
      laydate.render({
        elem: '#start' //指定元素
      });
      //执行一个laydate实例
      laydate.render({
        elem: '#end' //指定元素
      });
    });
    function delAll (argument) {
      var data = tableCheck.getData();
      layer.confirm('确认要删除吗？'+data,function(index){
          $.ajax({
              type:"POST",                      //请求类型
              url:"/SystemCenter/roleEdit?v=delete",                 //URL
              data:"ids="+data,                  //传递的参数
              dataType:"json",                 //返回的数据类型
              success:function(data){          //data就是返回的json类型的数据
                  console.log(data);
                  window.location.reload();
              }
          });
      });
    }
  </script>